package dao;

import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.ArrayList;

import bean.Aktie;
import bean.User;



public class Test {

	public static void main(String[] args) throws IOException, SQLException {
		
		//Login
		/*
		try {
			System.out.println(UserDAO.getInstance().checkLogin("supperstaar", "123456"));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		try {
			ArrayList anbieter = AktieDAO.getInstance().getAllAnbieter();
			System.out.println(anbieter.get(0));
			System.out.println(anbieter.get(1));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		*/
		//Neuer User

		/*
		User newUser = new User("Kuendig", "Pasci", "supperstaar", "123456", true, 29);
		try {
			System.out.println("Neuer User eingef�gt: " + UserDAO.getInstance().insertNewUser(newUser));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		*/
		/*
		User newUser = new User("Kuendig", "Pasci", "supperstaar", "123456", true, 29);
		try {
			System.out.println(AktieDAO.getInstance().getAllAvailableAktien().size());
		} catch (SQLException | IOException e) {
			e.printStackTrace();
		}	
		*/
		
		/*
		Aktie newAktie = new Aktie(false, 100, "", "Rabobank", "RABO", 101.00, 101.00);
		try {
			AktieDAO.getInstance().insertAktieIntoDB(2, newAktie);
		} catch (IOException | SQLException e) {
			e.printStackTrace();
		}
		*/
		/*
		try {
			System.out.println("Ergebnis sellAktie: " + AktieDAO.getInstance().sellAktie(4, "Credit Suisse", "CSS", 99.95, 3));
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		*/
		//AktieDAO.getInstance().buyAktie(52, 2);
		//AktieDAO.getInstance().berechneDividende(1, 100, "mittel");
	}

	/**
	 * @param input
	 * @return md5 
	 * @throws NoSuchAlgorithmException 
	 */
	public static String md5(String input) throws NoSuchAlgorithmException {
	    String md5 = null;
	    MessageDigest digest = MessageDigest.getInstance("MD5");
	    digest.update(input.getBytes(), 0, input.length());
	    md5 = new BigInteger(1, digest.digest()).toString(16);
	    return md5;
	}
}